package controlador;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import vista.VentanaPrincipal;

public class ControladorPrincipal implements ActionListener
{
	private VentanaPrincipal ventana;
	
	public ControladorPrincipal()
	{
		ventana= new VentanaPrincipal();
		ventana.addListener(this);
		visualizarVentana();
	}

	public void visualizarVentana()
	{
		ventana.setVisible(true);
	}
	
	public void actionPerformed(ActionEvent e) 
	{
		if (e.getActionCommand().equalsIgnoreCase("Clientes"))
		{
			new ControladorCliente(this);
			ventana.setVisible(false);
		}
		else if (e.getActionCommand().equalsIgnoreCase("Productos"))
		{		
			new ControladorProducto(this);
			ventana.setVisible(false);
		}
		else if (e.getActionCommand().equalsIgnoreCase("Ingredientes"))
		{		
			new ControladorIngrediente(this);
			ventana.setVisible(false);
		}
		else if (e.getActionCommand().equalsIgnoreCase("Proveedores"))
		{		
			new ControladorProveedor(this);
			ventana.setVisible(false);
		}
		else if (e.getActionCommand().equalsIgnoreCase("Categorias"))
		{		
			new ControladorCategoria(this);
			ventana.setVisible(false);
		}
		else if (e.getActionCommand().equalsIgnoreCase("Factura Venta"))
		{		
			new ControladorVenta(this);
			ventana.setVisible(false);
		}
		else if (e.getActionCommand().equalsIgnoreCase("Factura Compra"))
		{		
			new ControladorCompra(this);
			ventana.setVisible(false);
		}
		else if (e.getActionCommand().equalsIgnoreCase("Salir"))
		{
			ventana.setVisible(false);
			ventana.dispose();
			System.exit(0);
		}
		
	}
    
}
